<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 
<%
request.setCharacterEncoding("UTF-8"); 
//request.setCharacterEncoding("EUC-KR"); 
//System.out.println(request.getParameter("paramHtml"));

String content = request.getParameter("content") == null ? "" : request.getParameter("content");
String writer = request.getParameter("writer") == null ? " " : request.getParameter("writer");
String reviewer1 = request.getParameter("reviewer1") == null ? " " : request.getParameter("reviewer1");
String reviewer2 = request.getParameter("reviewer2") == null ? " " : request.getParameter("reviewer2");
String reviewer3 = request.getParameter("reviewer3") == null ? " " : request.getParameter("reviewer3");
String responsible = request.getParameter("responsible") == null ? " " : request.getParameter("responsible");
String date1 = request.getParameter("date1") == null ? " " : request.getParameter("date1");
String date2 = request.getParameter("date2") == null ? " " : request.getParameter("date2");
String date3 = request.getParameter("date3") == null ? " " : request.getParameter("date3");
String date4 = request.getParameter("date4") == null ? " " : request.getParameter("date4");
String date5 = request.getParameter("date5") == null ? " " : request.getParameter("date5");
String ctitle = request.getParameter("ctitle") == null ? " " : request.getParameter("ctitle");

// 전자증빙
String CoCode = request.getParameter("CoCode") == null ? "" : request.getParameter("CoCode");
String HgCode = request.getParameter("HgCode") == null ? " " : request.getParameter("HgCode");
String HgName = request.getParameter("HgName") == null ? " " : request.getParameter("HgName");
String UserId = request.getParameter("UserId") == null ? " " : request.getParameter("UserId");
String UserName = request.getParameter("UserName") == null ? " " : request.getParameter("UserName");
String KeyWord = request.getParameter("KeyWord") == null ? " " : request.getParameter("KeyWord");
String SlipdocKey = request.getParameter("SlipdocKey") == null ? " " : request.getParameter("SlipdocKey");

String ConnKey = request.getParameter("ConnKey") == null ? " " : request.getParameter("ConnKey");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>결재 요청서</title>

<link href="assets/css/print.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript">

	function drawContent(){
		document.getElementById("content").innerHTML = "<%=content%>";
	}
	var initBody;
	
	function beforePrint() {
		initBody = document.body.innerHTML;
		document.body.innerHTML = print_page.innerHTML;
	}
	function afterPrint() {
		document.body.innerHTML = initBody;
	}
	function pagePrint() {		
		//opener.parent.callFormAttach("X");
		window.onbeforeprint = beforePrint;
		window.onafterprint = afterPrint;
		//factory.printing.header = ""//머리글
		//factory.printing.footer = ""//바닥글
		//factory.printing.portrait = false; //true이면 세로 false이면 가로
		//factory.printing.leftMargin = 5.0 //왼쪽 마진
		//factory.printing.topMargin = 5.0 //상단 마진
		//factory.printing.rightMargin = 5.0 //오른쪽 마진
		//factory.printing.bottomMargin = 5.0 //하단 마진
		//factory.printing.Print(false, window)
		window.print();
	}
	function myClose() {
		window.opener='x';
		window.close();
	}

	///////////////////////////
	// 전자증빙 구동
	function OnInit()
	{
		window.resizeTo(640,710); //silver		
		//window.resizeTo(640,710); //silver
		//this.resizeTo(640,710);
		        		
		try
		{
			var strCoCode 	= document.all.CoCode.value;
			var strHgCode	= document.all.HgCode.value;
			var strHgName	= document.all.HgName.value;
			var strUserId	= document.all.UserId.value;
			var strUserName	= document.all.UserName.value;	
					
			//var strCoKey = "";
			//if( strCoCode == "1000" ) 		strCoKey = "ACE";
			//else if( strCoCode == "2000") 	strCoKey = "TOP";
			//else if( strCoCode == "3000") 	strCoKey = "ONS";
			
			var strCoKey = "";
			if( strCoCode == "ACE" )		
			{
				strCoKey = "ACE";
				strCoCode = "1000";
			} 
			else if(strCoCode == "TOP" ) 
			{
				strCoKey = "TOP";
				strCoCode = "2000";				
			}
			else if(strCoCode == "ONS" ) 
			{
				strCoKey = "ONS";
				strCoCode = "3000";				
			}			
				
			//////////////////////////////////////////
			// 전자증빙 업체 설정 및 운영 설정
			// 
			if( strCoCode == "ACE" ) 
			{
				OfficeXPSCtl.XpsSetRegKey(strCoKey, "PRD");	//PRD : 운영 시스템
			//	OfficeXPSCtl.XpsSetRegKey("ACE", "DEV");	//DEV : 개발 시스템 -> 현재 개발 시스템은 운영하지 않음
			//	OfficeXPSCtl.XpsSetRegKey("TOP", "PRD");	//TOP : 업체 TOP용 전자증빙
			//	OfficeXPSCtl.XpsSetRegKey("ONS", "PRD");	//ONS : 업체 ONS용 전자증빙
				
				//사용자 정보 설정
				var userInfo  = "<UserInfo>";
					userInfo += "<co_code>"+strCoCode+"</co_code>";			//업체코드 : ACE->1000, TOP->2000, ONS->3000
					userInfo += "<hg_code>"+strHgCode+"</hg_code>";			//코스트 센터 코드 -> 코스트 센터 코드가 틀릴 경우 로그인 불가
					userInfo += "<hg_name>"+strHgName+"</hg_name>";			//크스트 센터명
					userInfo += "<user_id>"+strUserId+"</user_id>";			//사번
					userInfo += "<user_name>"+strUserName+"</user_name>";	//사용자명
					userInfo += "<Auto_HgCode>1</Auto_HgCode>";				//기본 옵션
					userInfo += "<PTI_INFO>1</PTI_INFO>";
					userInfo += "</UserInfo>";
				
				var bInfo = document.OfficeXPSCtl.XpsSetInfo( userInfo );            
				if(bInfo == 1 )
				{
					//전자증빙 생성 성공
				}
			}

		
		}catch(e){}
	}	
		
</script>
</head>
<body onLoad="drawContent();OnInit();" >
	<table align="center" width="100%" height="43" border="0" cellspacing="0" cellpadding="0" >
	  <tr>
	  	<td align="right" class="printTop" valign="top" style="padding:5px 3px 0 0;">
			<img src="assets/images/btnPrint.gif" style="cursor: pointer;" onclick="pagePrint()" />
	  	</td>
	  </tr>
	</table>
	<Div id="print_page" style="margin-left:10px;margin-right:20px;margin-top:10px;width:570;height:200;display:inline;overflow:auto;overflow-y;" ms_positioning="FlowLayout">
		<table border="0" width="570" cellspacing="0" cellpadding="0" >
			<tr>
				<th width="69" rowspan="3" class="table_th01" >결재</th>
			    <th width="100" class="table_th">기안</th>
				<th colspan="3" class="table_th" >검토</th>
				<th width="100" class="table_th" >승인</th>
			</tr>
			<tr>
				<td class="table_td" width="100" align="center">&nbsp;<%=writer%></td>
				<td class="table_td" width="100" align="center">&nbsp;<%=reviewer1%></td>
				<td class="table_td" width="100" align="center">&nbsp;<%=reviewer2%></td>
				<td class="table_td" width="100" align="center">&nbsp;<%=reviewer3%></td>
				<td class="table_td" width="100" align="center">&nbsp;<%=responsible%></td>
		  </tr>
			<tr>
				<td class="table_td" align="center" height="20">&nbsp;<%=date1%></td>
				<td class="table_td" align="center">&nbsp;<%=date2%></td>
				<td class="table_td" align="center">&nbsp;<%=date3%></td>
				<td class="table_td" align="center">&nbsp;<%=date4%></td>
				<td class="table_td" align="center">&nbsp;<%=date5%></td>
			</tr>
		</table>
		<h1 class="title"><span class="title_blue">제목 :  </span><%=ctitle%></h1>
		<Div id="content" name="content"></Div>
	</Div>
	<table align="center" width="100%" height="43" border="0" cellspacing="0" cellpadding="0" >
		<tr>
			<td height="1" bgcolor="#bec6d1"></td>
		</tr>
		<tr>
			<td align="center" style="padding-top:5px;">
				<img src="assets/images/btn_close.gif" style="cursor: pointer;" onclick="myClose()" />
			</td>
		 	<input type="hidden" name="CoCode" value="<%=CoCode%>">
			<input type="hidden" name="HgCode" value="<%=HgCode%>">
			<input type="hidden" name="HgName" value="<%=HgName%>">
			<input type="hidden" name="UserId" value="<%=UserId%>">
			<input type="hidden" name="UserName" value="<%=UserName%>">
			<input type="hidden" name="KeyWord" value="<%=KeyWord%>">
			<input type="hidden" name="SlipdocKey" value="<%=SlipdocKey%>">
			
			<input type="hidden" name="ConnKey" value="<%=ConnKey%>">			
		</tr>
	</table>
	<object id=factory style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="/ScriptX.cab#Version=6,1,429,14">
	</object>

	<%
	if(CoCode.equals("ACE"))
	{
	%>
	<OBJECT id="OfficeXPSCtl" width="0" height="0" classid="CLSID:E2BAB9D1-0323-42AC-9D1F-C4C9AC984D5F"></OBJECT>
	<%
	}
	%>
		
</body>
</html>